home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 050 / pascal_s.arc / PASCAL-S.DOC < prev   
Encoding:
Text File  |  1985-04-17  |  16.0 KB  |  429 lines

  1.  
  2. PASCAL S Syntax Diagrams
  3. (All words in caps are required key words)
  4.  
  5.  
  6. program
  7.  
  8. ---> PROGRAM ---> identifier ---> ( ---> identifier list ---> ) ---> ; ---+
  9.                                                                           |
  10.           +-------------------------------------------------------------<-+
  11.           |
  12.           +--> block ------> .
  13.  
  14.  
  15. block
  16.  
  17. --+---> CONST -------> identifier --------> = ---> constant ---> ; ---+
  18.   |                                                                   |
  19.   +-<---------------------------------------------------------------<-+
  20.   |
  21.   +---> TYPE --------> identifier --------> = ---> type -------> ; ---+
  22.   |                                                                   |
  23.   +-<---------------------------------------------------------------<-+
  24.   |
  25.   +---> VAR ---------> identifier list ---> : ---> type -------> ; ---+
  26.   |                                                                   |
  27.   +-<---------------------------------------------------------------<-+
  28.   |
  29.   v
  30.   |
  31.   +-+-> PROCEDURE ---> identifier --------> formal parameter list  ---+
  32.   | ^                                                                 |
  33.   v |                                                                 |
  34.   +-+-<----------- ; <------- block <---------- ; <-------------------+
  35.   |                                                                   |
  36.   +---> FUNCTION ----> identifier ----> formal parameter list ---+    |
  37.   |                                                              |    |
  38.   |       +-<----------------------------------------------------+    |
  39.   |       |                                                           |
  40.   |       +---> : ----------> type identifier ---------------------->-+
  41.   |
  42.   +---> BEGIN -------> statement sequence -----> END ----->
  43.  
  44.  
  45. type
  46.  
  47. --+-----------------------> type identifier --------------------------------+->
  48.   |                                                                         |
  49.   +--> ARRAY --> [ -+> constant --> .. --> constant -+> ] --> OF --> type --+
  50.   |                 |                                |                      |
  51.   |                 +--------------  + <-------------+                      |
  52.   |                                                                         |
  53.   |              +->-------------------------------------->-+               |
  54.   |              |                                          |               |
  55.   +--> RECORD ---+-+-> identifier list ---> : ---> type -+--+-> END ------>-+
  56.                    |                                     |
  57.                    +----------------------- ; <----------+
  58.  
  59.  
  60. formal parameter list
  61.  
  62.   +->--------------------------------------------------------------------->-+
  63.   |                                                                         |
  64. --+-> ( -+-+->-------+--> identifier list --> : --> type identifier -+-> ) -+->
  65.          | |         |                                               |
  66.          | +-> VAR --+                                               |
  67.          |                                                           |
  68.          +-<--------------------------------- ; <--------------------+
  69.  
  70.  
  71. identifier list
  72.  
  73. -----------------+--->  identifier  ----+---------------------------->------->
  74.                  |                      |
  75.                  +--------- , <---------+
  76.  
  77.  
  78. identifier
  79.  
  80. -----------------> letter -----+--->-----------+--------------------->------->
  81.                                |               |
  82.                                +--- letter <---+
  83.                                |               |
  84.                                +--- digit  <---+
  85.  
  86.  
  87. statement sequence
  88.  
  89. -----------------+--->  statement   ----+---------------------------->------->
  90.                  |                      |
  91.                  +--------- , <---------+
  92.  
  93.  
  94. statement
  95.  
  96. --+--+-> variable -------------+--> := ----------------------------------->-+->
  97.   |  |                         |                                            |
  98.   |  +-> function identifier --+                                            |
  99.   |                                                                         |
  100.   +----> procedure identifier ----+---> actual parameter list ---+-------->-+
  101.   |                               |                              |          |
  102.   |                               +--->--------------------------+          |
  103.   |                                                                         |
  104.   +----> BEGIN ------> statement sequence ------> END -------------------->-+
  105.   |                                                                         |
  106.   |                                              +->------------------->-+  |
  107.   |                                              |                       |  |
  108.   +--> IF --> expression --> THEN --> statement -+-> ELSE --> statement -+--+
  109.   |                                                                         |
  110.   |                            +--->-------------------------------+        |
  111.   |                            |                                   |        |
  112.   +-> CASE -> expression -> OF +-+-> constant +-> : -> statement +-+-> END -+
  113.   |                              |            |                  |          |
  114.   |                              +----- , <---+                  |          |
  115.   |                              |                               |          |
  116.   |                              +--------------- ; <------------+          |
  117.   |                                                                         |
  118.   +----> WHILE ----> expression ------> DO ------> statement ------------->-+
  119.   |                                                                         |
  120.   +----> REPEAT ---> statement sequence ---> UNTIL ---> statement -------->-+
  121.   |                                                                         |
  122.   +----> FOR ------> variable identifier ---> := ---> expression --+        |
  123.   |                                                                |        |
  124.   |    +----<----------------------------------------------------<-+        |
  125.   |    |                                                                    |
  126.   |    +--+-> TO -------+--> expression ---> DO ---> statement ----------->-+
  127.   |       |             |                                                   |
  128.   |       +-> DOWN TO --+                                                   |
  129.   |                                                                         |
  130.   +---->------------------------------------------------------------------>-+
  131.  
  132.  
  133. expression
  134.  
  135. ---> simple expression --+---+---+---+---+---+------------------------->-+-->
  136.                          |   |   |   |   |   |                           |
  137.                          v   v   v   v   v   v                           |
  138.                          =   <>  <   >   >=  <=                          |
  139.                          |   |   |   |   |   |                           |
  140.                          +---+---+---+---+---+--> simple expression --->-+
  141.  
  142.  
  143. simple expression
  144.  
  145. ---+-->-----+--> term ----+--->-----------------+----+----+---------->------>
  146.    |        |             |                     |    |    |
  147.    +--> + --+             |                     v    v    v
  148.    |        |             |                     +    -    OR
  149.    +--> - --+             |                     |    |    |
  150.                           +---- term <----------+----+----+
  151.  
  152.  
  153. term
  154.  
  155. ------> factor -----------+--->------------+----+----+----+----+----->------>
  156.                           |                |    |    |    |    |
  157.                           |                v    v    v    v    v
  158.                           |                *    /   DIV  MOD  AND
  159.                           |                |    |    |    |    |
  160.                           +--- factor <----+----+----+----+----+
  161.  
  162.  
  163. factor
  164.  
  165. ---+--> unsigned constant --------------------------------------------->-+-->
  166.    |                                                                     |
  167.    +--> variable ------------------------------------------------------>-+
  168.    |                                                                     |
  169.    +--> function identifier ------> actual parameter list ------------->-+
  170.    |                                                                     |
  171.    +--> ( -------> expression ----> ) --------------------------------->-+
  172.    |                                                                     |
  173.    +--> NOT -----> factor --------------------------------------------->-+
  174.  
  175.  
  176. actual parameter list
  177.  
  178. ------> ( ------+---> expression ---+------> ) ---------------------->------>
  179.                 |                   |
  180.                 +-------- , <-------+
  181.  
  182.  
  183. variable
  184.  
  185. ----> variable identifier ---+----+--->------------------------------>------->
  186.                              |    |
  187.                              |    +---> [ --+--> expression --+--> ] --+
  188.                              |    |         |                 |        |
  189.                              |    |         +------- , <------+        |
  190.                              |    |                                    |
  191.                              |    +---> . -----> field identifier -->--+
  192.                              |                                         |
  193.                              +---<----------------------------------<--+
  194.  
  195.  
  196. constant
  197.  
  198. ---+---+-->-----+-----+---> unsigned number ---------------->-+------>------>
  199.    |   |        |     |                                       |
  200.    |   +--> + --+     |                                       |
  201.    |   |        |     +---> constant identifier ------------>-+
  202.    |   +--> - --+                                             |
  203.    |                                                          |
  204.    +----------------------> ' ----> character ----> ' ------>-+
  205.  
  206.  
  207. unsigned constant
  208.  
  209. ---+------> constant identifier ---------------------------->-+------>------>
  210.    |                                                          |
  211.    +------> unsigned number -------------------------------->-+
  212.    |                                                          |
  213.    +------> ' ----> character ----> ' ---------------------->-+
  214.  
  215.  
  216. unsigned number
  217.  
  218. ---> unsigned integer ---+--->----------------------------------+->-+------->
  219.                          |                                      |   |
  220.                          +---> . ----> unsigned integer --+--->-+   |
  221.                          |                                |         |
  222.                          v                                |         |
  223.                          +---<-------------------------<--+         |
  224.                          |                                          |
  225.                          +---> E --+-->-----+-> unsigned integer ->-+
  226.                                    |        |
  227.                                    +--> + --+
  228.                                    |        |
  229.                                    +--> - --+
  230.  
  231.  
  232. unsigned number
  233.  
  234. ------------------------+-----> digit -----+------------------------->------>
  235.                         |                  |
  236.                         +-----<------------+
  237.  
  238.  
  239.  
  240. The first 10 characters are significant in identifiers (variables)
  241.  
  242. Types supported by PASCAL-S
  243.  
  244.        integer
  245.        real
  246.        boolean
  247.        char
  248.  
  249. Records and arrays are supported
  250.  
  251.  
  252. All standard builtin functions are supported
  253.  
  254.        abs     atan    chr     cos
  255.        eof     eoln    exp     ln
  256.        odd     ord     pred    round
  257.        sin     sqr     sqrt    succ
  258.        trunc
  259.  
  260.  
  261. Builtin procedures supported
  262.  
  263.        read
  264.        readln
  265.        write
  266.        writeln
  267.  
  268.  
  269. Compiler/Interpreter options
  270.  
  271. A comment that has the character '$' as its first character is used to
  272. specify compiler options.  These take the form of a letter followed by
  273. a plus sign (option on) or a minus sign (option off).  All options
  274. default to off.  The following options are available:
  275.  
  276.        T : Symbol table to be printed (to list file)
  277.        S : Run time stack printed (to list file) on entry to procedure
  278.  
  279.  
  280. Pascal-S Error Summary
  281.  
  282.  0  undefined identifier
  283.  1  attempt at multiple definition
  284.  2  identifier expected (but not found)
  285.  3  'program' expected (but not found)
  286.  4  ')` expected (but not found)
  287.  5  ':' expected (but not found)
  288.  6  illegal symbol
  289.  7  error in formal parameters list
  290.  8  'of' expected
  291.  9  '(' expected
  292. 10  type error
  293. 11  '[' expected
  294. 12  ']' expected
  295. 13  '..' expected
  296. 14  ';' expected
  297. 15  error in function result type
  298. 16  '=' expected
  299. 17  expression must have boolean result
  300. 18  control variable must be of type variable
  301. 19  type conflict between control variable and expression
  302. 20  error in program parameter list
  303. 21  number too large
  304. 22  '.' expected
  305. 23  invalid expression type following case
  306. 24  illegal character
  307. 25  identifier of type constant expected
  308. 26  array index type conflict
  309. 27  type conflict in declaration of array index bounds
  310. 28  no such array
  311. 29  error on type of identifier
  312. 30  undefined type
  313. 31  no such record
  314. 32  boolean type expected
  315. 33  arithmetic type expected
  316. 34  integer type expected
  317. 35  invalid operator
  318. 36  actual/formal parameter type conflict
  319. 37  item must be of type variable
  320. 38  string expected
  321. 39  not enough actual parameters
  322. 40  no digits after decimal point
  323. 41  incorrect type
  324. 42  type real expected
  325. 43  integer expected
  326. 44  variable of constant expected
  327. 45  variable of procedure identifier expected
  328. 46  type conflict in operands
  329. 47  label type incompatable with selecting expression
  330. 48  incorrect type of expression for standard function
  331. 49  store overflow
  332. 50  constant expected
  333. 51  ';=' expected
  334. 52  'then' expected
  335. 53  'until' expected
  336. 54  'do' expected
  337. 55  'to' or 'down to' expected
  338. 56  'begin' expected
  339. 57  'end' expected
  340. 58  factor expected
  341.  
  342.  
  343. Pascal-S operation codes
  344. (These are shown in the list file when the T option is selected)
  345.  
  346. Code  x  y  Action
  347.    0  x  y  Load address
  348.    1  x  y  Load value
  349.    2  x  y  Load indirect
  350.    3  x  y  Update DISPLAY
  351.    4          not used
  352.    5          not used
  353.    6          not used
  354.    7          not used
  355.    8     y  Standard functions (selected by 0 .. 18)
  356.    9     y  Add y to the element on top of the stack
  357.   10     y  Jump to y (unconditional)
  358.   11     y  Jump to y if stack top false
  359.   12     y  Jump to y (case table) and select entry
  360.   13     y  Entry in case table ... NOT EXECUTABLE
  361.   14     y  For loop entry test - UP
  362.   15     y  For loop retry test - UP
  363.   16     y  For loop entry test - DOWN
  364.   17     y  For loop retry test - DOWN
  365.   18     y  Mark stack
  366.   19     y  Call user procedure
  367.   20     y  Indexed fetch (element size <> 1)
  368.   21     y  Indexed fetch
  369.   22     y  Load block
  370.   23     y  Copy block
  371.   24     y  Load literal
  372.   25     y  Load real
  373.   26     y  Float
  374.   27     y  Read (y denotes type .. 1 integer, 2 real, 4 char)
  375.   28     y  Write string
  376.   29     y  Write .. default field widths
  377.   30     y  Write .. given field widths
  378.   31        HALT
  379.   32        Exit procedure
  380.   33        Exit function
  381.   34        Fetch
  382.   35        Not
  383.   36        Negate
  384.   37        Write real .. given field widths
  385.   38        Store
  386.   39        Real =
  387.   40        Real <>
  388.   41        Real <
  389.   42        Real <=
  390.   43        Real >
  391.   44        Real >=
  392.   45        Integer =
  393.   46        Integer <>
  394.   47        Integer <
  395.   48        Integer <=
  396.   49        Integer >
  397.   50        Integer >=
  398.   51        Or
  399.   52        + integer
  400.   53        - integer
  401.   54        + real
  402.   55        - real
  403.   56        And
  404.   57        * integer
  405.   58        Div
  406.   59        Mod
  407.   60        * real
  408.   61        /
  409.   62        Readln
  410.   63        Writeln
  411.  
  412.  
  413.  
  414.  
  415. A special thanks to Anthony Marcy and Phil Windley for their help
  416. on this project.  If you should have and comments or improvements to
  417. the Pascal-S compiler/interpreter, please contact:
  418.  
  419.        John Naleszkiewicz
  420.        (301)468-1439 (data)
  421.        6:30pm to 8:30am weekdays
  422.        24Hrs weekends.
  423.  
  424. 
  425.  
  426. 
  427.  
  428.        John Naleszkiewicz
  429.        (301)468-1439 (dat